<?php
    if (!defined('EXPONENT')) exit('');
    if (exponent_users_isAdmin() ||  exponent_permissions_check(array("administrate","upload","delete","meeting","meeting_delete","meeting_assistant"),exponent_core_makeLocation("profilemodule","_syscore","")))
    {   
        exponent_flow_set(SYS_FLOW_PROTECTED,SYS_FLOW_ACTION);
        global $db;              

        require_once(BASE."modules/formhelpermodule/formhelper.php");
        $formhelper=new formhelper("profilemodule","Manage Clients Profile","_profile_manage",$loc);
        $formhelper->setGridType(FORMHELPER_GRID_TYPE_DATAGRID);
        $formhelper->setGridOptions("height",657);
        $formhelper->setGridOptions("idField","id");
        $formhelper->setGridOptions("pagination",1);
        $formhelper->setGridOptions("pageNumber","1");
        $formhelper->setGridOptions("pageSize","20");
        $formhelper->setGridOptions("rownumbers","true");
        $formhelper->setGridOptions("nowrap","false");
        $formhelper->setGridOptions("singleSelect","true");
        $formhelper->setGridOptions("autoRowHeight","true");
        $formhelper->setGridOptions("onDblClickRow","function(___grid_syslog_dbrow");

        $formhelper->setGridID("manage_profile");

        $css=URL_FULL."modules/profilemodule/css/manage.css";
        $formhelper->addCss($css);

        $formhelper->setColumnType(1);
        $formhelper->addColumn(array("field"=>"firstname","title"=>"First name",'width'=>120));
        $formhelper->addColumn(array("field"=>"lastname","title"=>"Last name",'width'=>120));
        $formhelper->addColumn(array("field"=>"company_name","title"=>"Company name",'width'=>140));
        $formhelper->addColumn(array("field"=>"email","title"=>"email",'width'=>130));
        $formhelper->addColumn(array("field"=>"skype","title"=>"Skype",'width'=>110));       
        $formhelper->addColumn(array("field"=>"tel1","title"=>"Phone",'width'=>100));       
        $formhelper->addColumn(array("field"=>"website","title"=>"Website",'width'=>100));       
        
        
        $link_param="/index.php?module=profilemodule&action=manage_ajax&src={$loc->src}&ajax_action=1";
        $formhelper->setURLDataStream($link_param);
        $formhelper->setGridOptions("onBeforeLoad","function(___form_onBeforeLoad");

        $toolbar_template=new template("profilemodule","profile_toolbar",$loc);
        $toolbar_template->assign('mod',$mod);
        $toolbar_template->register_permissions(array('administrate',"configure"),$loc);
        $toolbar_html=$toolbar_template->render();
        $formhelper->addToolbarHTML($toolbar_html);
        $formhelper->addToolbarStyle("height: 70px;");

        $formhelper->setPreInitJSCall("form_syslog_preinit");
        $formhelper->register_permissions(array('administrate',"configure"),$loc);

        exponent_sessions_set("AB_THEME_TOP_CONTAINER_SRC","top_loginmodule_".LANG);
        exponent_sessions_set("AB_THEME_TOP_CONTAINER_TYPE","textmodule");

        $html = $formhelper->render();
        
        // render main page
        $template=new template("profilemodule","_profile_manage",$loc);
        $template->assign('html',$html);
        $template->register_permissions(array('administrate',"configure"),$loc);
        $template->output();

    }
    else
    {
        echo exponent_http_error(403);
    }
?>
